package org.nox.helloseries.util;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.nox.helloseries.domain.Serie;

public final class SeriePrettyPrinter
{
    public static String rssPrettyPrint( List<Serie> retour )
    {
        StringBuilder builder = new StringBuilder();
        builder.append( "[\n" );
        for ( Serie serie : retour )
        {
            builder.append( prettyPrintMe( "nom", serie.getNom() ) );
            builder.append( prettyPrintMe( "saison", serie.getSaison() ) );
            builder.append( prettyPrintMe( "episode", serie.getEpisode() ) );
            builder.append( prettyPrintMe( "version", serie.getVersion() ) );
            builder.append( prettyPrintMe( "qualite", serie.getQualite() ) );
            builder.append( prettyPrintMe( "url", serie.getSerieFileInformation().getUrl() ) );
            builder.append( prettyPrintMe( "infos", serie.getSerieFileInformation().getInfos() ) );
            builder.append( ",\n" );
        }
        builder.append( "]" );
        return builder.toString();
    }

    public static String prettyPrintMe( String libelle, Object valeur )
    {
        if ( valeur != null && StringUtils.isNotEmpty( valeur.toString() ) )
        {
            return "[" + libelle + "=" + valeur + "]";
        }
        return "";
    }
}
